<? if(!defined('IN_TIPASK')) exit('Access Denied'); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd"><? $user=$this->user; $setting=$this->setting; ?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Tipask's Control Panel</title>
<meta http-equiv="Content-Type" content="text/html; charset=<?=TIPASK_CHARSET?>">
<link media="all" type="text/css" href="css/common/admin/admincp.css" rel="stylesheet" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/dialog.js" type="text/javascript"></script>
<script src="js/admin.js" type="text/javascript"></script>
<script src="js/calendar.js" type="text/javascript"></script>
</head>
<body>
<div id="append">
</div>
<div class="container"><? if(isset($message)) { $type=isset($type)?$type:'correctmsg';  ?><div class="<?=$type?>"><p><?=$message?></p></div><? } ?><div class="hastabmenu">
<ul class="tabmenu">
<li class="tabcurrent" id="srchuserbtn">
<a href="index.php?admin_question/default<?=$setting['seo_suffix']?>">问题搜索</a></li>
<li id="adduserbtn"><a href="index.php?admin_question/searchanswer<?=$setting['seo_suffix']?>">回答搜索</a></li>
</ul>
<div class="tabcontentcur" id="srchuserdiv">
<form action="index.php?admin_question/searchquestion<?=$setting['seo_suffix']?>" method="post">
<table width="100%">
<tr>
<td>标题:</td>
<td>
<input class="txt" name="srchtitle" <? if(isset($srchtitle)) { ?>value="<?=$srchtitle?>" <? } ?>></td>
<td>提问者:</td>
<td>
<input class="txt" name="srchauthor" <? if(isset($srchauthor)) { ?>value="<?=$srchauthor?>" <? } ?>></td>
<td>问题状态</td>
<td>
<select name="srchstatus">
<option <? if((isset($srchstatus) && '-1'==$srchstatus) ) { ?> selected <? } ?> value="-1">--不限--</option>
<option value="0" <? if((isset($srchstatus) && 0==$srchstatus) ) { ?> selected <? } ?>>未审核</option>
<option value="1" <? if((isset($srchstatus) && 1==$srchstatus) ) { ?> selected <? } ?>>待解决</option>
<option value="2" <? if((isset($srchstatus) && 2==$srchstatus) ) { ?> selected <? } ?>>已解决</option>
<option value="3" <? if((isset($srchstatus) && 3==$srchstatus) ) { ?> selected <? } ?>>投票中</option>
<option value="4" <? if((isset($srchstatus) && 4==$srchstatus) ) { ?> selected <? } ?>>高分</option>
<option value="5" <? if((isset($srchstatus) && 5==$srchstatus) ) { ?> selected <? } ?>>零回答</option>
<option value="6" <? if((isset($srchstatus) && 6==$srchstatus) ) { ?> selected <? } ?>>推荐问题</option>
<option value="7" <? if((isset($srchstatus) && 7==$srchstatus) ) { ?> selected <? } ?>>快到期</option>
<option value="8" <? if((isset($srchstatus) && 8==$srchstatus) ) { ?> selected <? } ?>>过期问题</option>
<option value="9" <? if((isset($srchstatus) && 9==$srchstatus) ) { ?> selected <? } ?>>已关闭问题</option>
</select>
</td>
</tr>
<tr>
<td>提问时间:</td>
<td colspan="3">
<input class="txt" onclick="showcalendar();" name="srchdatestart" <? if(isset($srchdatestart)) { ?>value="<?=$srchdatestart?>" <? } ?>> 
到&nbsp; 
<input class="txt" onclick="showcalendar();" name="srchdateend" <? if(isset($srchdateend)) { ?>value="<?=$srchdateend?>" <? } ?>></td>
<td colspan="2" align="center">
<input class="btn" name="submit" type="submit" value="搜 索">
</td>
</tr>
</table>
</form>
</div>
</div>
<br>
<h4>[共 <?=$rownum?> 个问题]</h4>
<div class="mainbox">
<form name="queslist" method="POST">
<table class="datalist fixwidth" >
<tr>
<th><input class="checkbox" id="chkall" onclick="checkall('qid[]')" type="checkbox" name="chkall"><label for="chkall">全选</label></th>
<th>标题</th>
<th>提问者</th>
<th>悬赏分</th>
<th>回答数</th>
<th>状态</th>
<th>提问时间</th>
<th>已审核</th>
<th>已推荐</th>
</tr><? if(isset($questionlist)) { ?> 
<? if(is_array($questionlist)) { foreach($questionlist as $question) { ?>
<tr>
<td class="option">
<input class="checkbox" type="checkbox" value="<?=$question['id']?>" name="qid[]" >
</td>
<td id="title_<?=$question['id']?>"><a href="index.php?question/view/<?=$question['id']?><?=$setting['seo_suffix']?>" target="_blank"><?=$question['title']?></a></td>
<td><a href="index.php?user/space/<?=$question['authorid']?><?=$setting['seo_suffix']?>" target="_blank"><?=$question['author']?></a></td>
<td><?=$question['price']?></td>
<td><?=$question['answers']?></td>
<td><img src="<?=SITE_URL?>css/common/icn_<?=$question['status']?>.gif"></td>
<td><?=$question['format_time']?></td>
<td><? if($question['status']) { ?><font color="Red">是</font><? } else { ?>否<? } ?></td>
<td><? if($question['status']==6) { ?><font color="Red">是</font><? } else { ?>否<? } ?></td>
</tr><? $content=htmlspecialchars($question['description']); ?><input type="hidden" id="cont_<?=$question['id']?>" value="<?=$content?>" >
<? } } ?>
 <? } ?><tr class="nobg">
<td class="tdpage" colspan="9">	<div class="pages">	<?=$departstr?></div></td>
</tr>
<tr class="nobg">
<td colspan="8">
<input name="ctrlcase" class="btn" type="button" onClick="buttoncontrol(1);" value="审核" />&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="button" onClick="buttoncontrol(2);" value="推荐">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="submit" onClick="buttoncontrol(3);" value="取消推荐">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="button" onClick="renametitle();" value="修改标题">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="button" onClick="editcont();" value="修改问题内容">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="button" onClick="movecate();" value="移动分类">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="submit" onClick="buttoncontrol(4);" value="关闭问题">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="submit" onClick="buttoncontrol(5);" value="设为待解决">&nbsp;&nbsp;&nbsp;
<input name="ctrlcase" class="btn" type="submit" onClick="buttoncontrol(6);" value="删除">
</td>
</table>
</form>
</div>
</div>
</body>
<script src="js/editor/kindeditor.js" type="text/javascript"></script>
<script type="text/javascript">
function buttoncontrol(num){
   	if($("input[name='qid[]']:checked").length==0){
   		alert('你没有选择任何要操作的问题！');
return false;
  	 }else{
switch(num){
case 1:
if(confirm('此操作只对未审核问题有效，继续?')==false){
return false;
}else{
document.queslist.action="index.php?admin_question/verify<?=$setting['seo_suffix']?>";
document.queslist.submit();
}
break;
case 2:
if(confirm('确定推荐？此项操作只对已解决问题有效！')==false){
return false;
}else{
document.queslist.action="index.php?admin_question/recommend<?=$setting['seo_suffix']?>";
document.queslist.submit();
}
break;
case 3:
document.queslist.action="index.php?admin_question/inrecommend<?=$setting['seo_suffix']?>";
document.queslist.submit();
break;
case 4:
if(confirm('确定关闭问题？')==false){
return false;
}else{
document.queslist.action="index.php?admin_question/close<?=$setting['seo_suffix']?>";
document.queslist.submit();
}

break;
case 5:
if(confirm('确定设为待解决？此项操作只对已解决和已关闭问题有效！')==false){
return false;
}else{
document.queslist.action="index.php?admin_question/nosolve<?=$setting['seo_suffix']?>";
document.queslist.submit();
}

break;
case 6:
if(confirm('确定删除问题？该操作不可返回！')==false){
return false;
}else{
document.queslist.action="index.php?admin_question/delete<?=$setting['seo_suffix']?>";
document.queslist.submit();
}
break;
 	default:
 		alert("非法操作！");
 	break;	
}
}
}
function renametitle(){
if ($("input[name='qid[]']:checked").length > 1){
alert('只能同时对一个问题进行操作！');
return false;
}else if($("input[name='qid[]']:checked").length == 0){
alert('你没有选择任何问题');
return false;
}else{
var qid = $("input[name='qid[]']:checked").val();
var title = $('#title_'+qid).text();
$.dialog({
    id:'renametitle',
    position:'center',
    align:'left',
    fixed:1,
    width:300,
    height:100,
    title:'修改问题标题',
    fnOk:function(){document.renameForm.submit();$.dialog.close('renametitle')},
    fnCancel:function(){$.dialog.close('renametitle')},
    content:'<div class="mainbox"><form name="renameForm"  action="index.php?admin_question/renametitle<?=$setting['seo_suffix']?>" method="post" ><input type="hidden" value="'+qid+'" name="qid"/>问题标题：<br /><input type="text" name="title" value="'+title+'" class="txt" size="45" /></form></div>'
  });
}
}
function editcont(){
if ($("input[name='qid[]']:checked").length > 1){
alert('只能同时对一个问题进行操作！');
return false;
}else if($("input[name='qid[]']:checked").length == 0){
alert('你没有选择任何问题');
return false;
}else{
var qid = $("input[name='qid[]']:checked").val();
var content = $('#cont_'+qid).val();
var title = $('#title_'+qid).text();
$.dialog({
    id:'editquesDiv',
    position:'center',
    align:'left',
    fixed:1,
    width:600,
    title:'修改问题内容',
    fnOk:function(){document.editquescontForm.submit();$.dialog.close('editquesDiv')},
    fnCancel:function(){$.dialog.close('editquesDiv')},
    content:'<div>标题：'+title+'<br /><form name="editquescontForm"  action="index.php?admin_question/editquescont<?=$setting['seo_suffix']?>" method="post" ><textarea id="mc" name="content" style="width: 95%; padding-top: 1px; font-size: 14px;" rows="10" >'+content+'</textarea><input type="hidden"  value="'+qid+'" name="qid"/></form></div>'
  });
KE.init({
id : 'mc',
resizeMode : 1,
allowUpload : false,
newlineTag : 'br',
items : [
'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
'insertunorderedlist', '|', 'image', 'link']
});
KE.create('mc');
}
}
function movecate(){
if($("input[name='qid[]']:checked").length == 0){
alert('你没有选择任何问题');
return false;
}else{
var qids = document.getElementsByName('qid[]');
var num='',tag='';
for(var i=0;i<qids.length;i++){	
if(qids[i].checked==true){
num+=tag+qids[i].value;
tag=",";
}
}
$.dialog({
    id:'editcatediv',
    position:'center',
    align:'left',
    fixed:1,
    width:300,
    height:100,
    title:'移动分类',
    fnOk:function(){document.askform.submit();$.dialog.close('editcatediv')},
    fnCancel:function(){$.dialog.close('editcatediv')},
    content:'<div class="mainbox">请选择要移动到的分类：<form name="askform" action="index.php?admin_question/movecategory<?=$setting['seo_suffix']?>" method="post" ><input type="hidden" name="qids" value="'+num+'" /><select name="category" size=1 style="width:240px" ><?=$catetree?></select></form></div>'
  });
}
}
</script>
</html>
